﻿Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Partial Public Class ProjectView

    Public Sub Refresh(ByVal Project As Project, ByVal View As Node.TreeType)
        Dim Nodes As NodeCollection = Nothing
        Select Case View
            Case Node.TreeType.Area
                Nodes = Project.AreaRootNodes
            Case Node.TreeType.Iteration
                Nodes = Project.IterationRootNodes
        End Select
        ux_Grid.Children.Clear()
        '----------------------------
        Dim TotalWidthInUnits As Integer = 0

        For Each Node As Node In Nodes
            TotalWidthInUnits = TotalWidthInUnits + Node.ComputeWidthInNodes
        Next

        Dim r As New RowDefinition
        r.Height = New GridLength(0, GridUnitType.Auto)
        ux_Grid.RowDefinitions.Add(r)
        For count As Integer = 0 To Nodes.Count - 1
            Dim c As New ColumnDefinition
            c.Width = New GridLength(Nodes(count).ComputeWidthInNodes * 310)
            ux_Grid.ColumnDefinitions.Add(c)
            Dim x As New NodeView
            x.Width = Nodes(count).ComputeWidthInNodes * 310
            'x.Height = ux_Grid.ActualHeight - 10
            x.Refresh(Project, Nodes(count))

            ux_Grid.Children.Add(x)
            Grid.SetColumn(x, count)
        Next
    End Sub

End Class